package com.sm.filemanagelibrary.adapter;

import androidx.annotation.Nullable;

import com.scorpio.baselibrary.adapter.BasicQuickAdapter;
import com.scorpio.baselibrary.adapter.BasicViewHolder;
import com.scorpio.baselibrary.utils.FileUtil;
import com.sm.filemanagelibrary.R;
import com.sm.filemanagelibrary.model.FileCacheEntity;

import java.util.List;

/**
 * created by zhud on 2019/9/27
 */
public class FileRootPathAdapter extends BasicQuickAdapter<FileCacheEntity, BasicViewHolder> {
    public FileRootPathAdapter(@Nullable List<FileCacheEntity> data) {
        super(R.layout.item_file_root_path_layout, data);
    }

    @Override
    protected void convert(BasicViewHolder helper, FileCacheEntity item) {
        String pathName;
        if (item.path.equals(FileUtil.getSDPath())) {
            pathName = getString(R.string.file_string_00003);
        } else {
            String[] tsn = item.path.split("/");
            pathName = tsn.length > 0 ? tsn[tsn.length - 1] : "";
        }
        helper.addOnClickListener(R.id.root_path_item_layout).setText(R.id.file_path, pathName);
    }
}
